package com.wsk.write;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by Maibenben on 2017/1/5.
 */
public class WriteTxt {
    private static ArrayList writeTxt() throws IOException {
        ArrayList<String> list = new ArrayList<>();
        String encoding = "GBK";
        File file = new File("txt/cc.txt");
        InputStreamReader reader = new InputStreamReader(new FileInputStream(file), encoding);
        BufferedReader bufferedReader = new BufferedReader(reader);
        String cc = "";
        String[] list1 ;
        while ((cc = bufferedReader.readLine()) != null) {
            list1 = cc.split(",");
            Collections.addAll(list, list1);
        }
        reader.close();
        File file1 = new File("txt/cc2.txt");
        BufferedWriter writer = new BufferedWriter(new FileWriter(file1));
        for (int i=0;i<list.size();i++){
            writer.write(list.get(i));
            writer.newLine();
        }
        writer.close();
        return list;
    }

    public static void main(String[] args) throws IOException {
        writeTxt();
    }
}
